﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; 

namespace Journey_dalSql
{
    public class BasePage:System.Web.UI.Page 
    {
        public BasePage()
        {  }
        /// <summary>
        /// 重写基类Page中的OnInit方法
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Load += new System.EventHandler(PageBase_Load);
        }
        private void PageBase_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (HttpContext.Current.Session["username"] == null)
                {
                    HttpContext.Current.Response.Redirect("~/Login.htm");
                }
            }
        }
        #region 专门用来设置Cookie
        private void setCookie(string CookieName, string CookieValue)
        {
            HttpCookie Code = new HttpCookie(CookieName);
            Code.Value = CookieValue;
            HttpContext.Current.Response.Cookies.Add(Code);
        }
        #endregion

    }
}
